package classLoader;

import org.junit.Test;

public class MainTest {

	@Test
	public void testMyClassLoader() throws IllegalAccessException, InstantiationException, ClassNotFoundException {
		MyClassLoader myClassLoader = new MyClassLoader("D:\\version\\code\\study\\target\\classes\\classLoader\\");
		String name = "classLoader.Student";
		Class studentClass = myClassLoader.loadClass(name);
		Student student = (Student) studentClass.newInstance();
		student.sayHello();
	}

	@Test
	public void testLoadClassAndForName() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		System.out.println("----开始loadClass----");
		Student.class.getClassLoader().loadClass("classLoader.Student");
		System.out.println("----结束loadClass----");

		System.out.println("----开始Class.forName----");
		Class student = Class.forName("classLoader.Student");
		System.out.println("----结束Class.forName----");
	}
}
